package cn.edu.sdjzu.xg.bysj.service;

import cn.edu.sdjzu.xg.bysj.dao.MajorDao;
import cn.edu.sdjzu.xg.bysj.domain.Major;

import java.sql.SQLException;
import java.util.Collection;

public final class MajorService {
    //获取MajorDao实例
    private static MajorDao majorDao= MajorDao.getInstance();
    //新建MajorService对象
    public static MajorService majorService = new MajorService();
    //构造器
    private MajorService(){}
    //获取MajorService对象
    public static MajorService getInstance(){
        return majorService;
    }
    //根据id查找Major
    public Major find(int id) throws SQLException {
        return majorDao.find(id);
    }
    //查找所有Major
    public Collection<Major> findAll() throws SQLException {
        return majorDao.findAll();
    }
    //根据id删除Major
    public boolean delete(int id) throws SQLException {
        Major major = this.find(id);
        return majorDao.delete(major);
    }
    //删除Major
    public boolean delete(Major major) throws SQLException {
        return MajorDao.getInstance().delete(major);
    }
    //更新Major
    public boolean update(Major major) throws SQLException {
        return majorDao.update(major);
    }
    //新增Major
    public boolean add(Major major) throws SQLException {
        return majorDao.add(major);
    }
}
